<template>
  <div class="container">
    <!-- 横向步骤条 -->
    <div class="step">
      <div class="item" v-for="(item, index) of dataSource" :key="index">
        <div class="line" :class="{ line_act: item.checked }" v-if="index !== dataSource.length - 1"></div>
        <img class="img" :src="activeStep" v-if="item.checked" />
        <img class="img" :src="step" v-if="!item.checked" />
        <div class="name" :class="{ name_act: item.checked }">
          {{ item.name }}
        </div>
        <div class="time">
          {{ item.time }}
        </div>
      </div>
    </div>
    <slot></slot>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue'
import activeStep from '@/assets/image/waybill/step_active.png'
import step from '@/assets/image/waybill/step_normal.png'

export default defineComponent({
  name: 'StepBar',
  props: {
    dataSource: {
      type: Array as PropType<any[]>,
      required: true
    }
  },
  setup() {
    return {
      activeStep,
      step
    }
  }
})
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  background: white;
  padding: 12px 0;
  box-sizing: border-box;
  .step {
    display: flex;
    overflow: hidden;
    .item {
      position: relative;
      display: flex;
      // justify-content: space-around;
      // text-align: center;
      flex: 1;
      align-items: center;
      flex-direction: column;
    }
    .img {
      width: 28px;
      height: 28px;
      vertical-align: middle;
    }
    .line {
      position: absolute;
      top: 13px;
      left: 43px;
      width: 58px;
      border-bottom: 2px solid rgba(64, 158, 255, 30%);
      &_act {
        border-bottom: 2px solid rgba(64, 158, 255, 30%);
      }
    }
    .name {
      margin-top: 10px;
      font-size: 12px;
      color: #575c72;
      &_act {
        color: #409eff;
      }
    }
    .time {
      margin-top: 6px;
      text-align: center;
      font-size: 12px;
      color: #575c72;
    }
    // .current {
    //   border-bottom: 2px solid #409eff;
    // }
    // .cur1 {
    //   color: #409eff;
    // }
  }
}
</style>
